package fun.xinnix.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class FanoutConfig {
    @Bean
    public FanoutExchange fanoutExchange() {
        return ExchangeBuilder.fanoutExchange("demo.fanout").build();
    }

    @Bean(name = "fanoutQueue")
    public Queue fanoutQueue() {
        return QueueBuilder.durable("demo.fanout.queue").build();
    }

    @Bean(name = "fanoutBinding")
    public Binding fanoutBinding(@Qualifier("fanoutQueue") Queue queue, FanoutExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange);
    }
}
